/*
 * Package il.ac.biu.cs.grossmm.impl.keys
 * File KeyFactoryTest.java
 * Created on Sep 5, 2006
 *
 */
package il.ac.biu.cs.grossmm.junit_api_tests.keys;



import static il.ac.biu.cs.grossmm.api.keys.KeyFactory.entry;
import static il.ac.biu.cs.grossmm.api.keys.KeyFactory.key;
import static il.ac.biu.cs.grossmm.api.presence.BaseVocabulary.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import il.ac.biu.cs.grossmm.api.keys.Attribute;
import il.ac.biu.cs.grossmm.api.keys.Key;

import org.junit.Test;

public class KeyFactoryTest {

    enum A implements Attribute {
        FOO, BAR
    }
    
    @Test
    public void testNull() {
       Key key = key((Object) null);
       assertNull(key.value());
    }
    
    @Test
    public void testValue() {
       String value = "Hello world";
       Key key = key(value);
       assertEquals(value, key.value());
    }
    
    @Test
    public void testEntries() {
       Key key = key(
               entry(WATCHER, "Bob"),
               entry(FILTER, "no-winfo")
               );
       
       assertEquals(2, key.size());
       assertEquals("Bob", key.value(WATCHER));
       assertEquals("no-winfo", key.value(FILTER));
       assertNull(key.value(A.FOO));
    }
}


